import gettext

from Components.Language import language
from Tools.Directories import resolveFilename, SCOPE_PLUGINS


PluginLanguageDomain = "iptv-org-playlists"
PluginLanguagePath = "Extensions/iptv-org-playlists/locale"


def pluginlanguagedomain():
	return PluginLanguageDomain


def localeInit():
	gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))


def _(txt):
	if translated := gettext.dgettext(PluginLanguageDomain, txt):
		return translated
	else:
		print("[" + PluginLanguageDomain + "] fallback to default translation for " + txt)
		return gettext.gettext(txt)


localeInit()
language.addCallback(localeInit)


group_titles = {
	# countries
	"Afghanistan": _("Afghanistan"),
	"Albania": _("Albania"),
	"Algeria": _("Algeria"),
	"American Samoa": _("American Samoa"),
	"Andorra": _("Andorra"),
	"Angola": _("Angola"),
	"Anguilla": _("Anguilla"),
	"Antigua and Barbuda": _("Antigua and Barbuda"),
	"Argentina": _("Argentina"),
	"Armenia": _("Armenia"),
	"Aruba": _("Aruba"),
	"Australia": _("Australia"),
	"Austria": _("Austria"),
	"Azerbaijan": _("Azerbaijan"),
	"Bahamas": _("Bahamas"),
	"Bahrain": _("Bahrain"),
	"Bangladesh": _("Bangladesh"),
	"Barbados": _("Barbados"),
	"Belarus": _("Belarus"),
	"Belgium": _("Belgium"),
	"Belize": _("Belize"),
	"Benin": _("Benin"),
	"Bermuda": _("Bermuda"),
	"Bolivia": _("Bolivia"),
	"Bonaire": _("Bonaire"),
	"Bosnia and Herzegovina": _("Bosnia and Herzegovina"),
	"Botswana": _("Botswana"),
	"Brazil": _("Brazil"),
	"British Virgin Islands": _("British Virgin Islands"),
	"Brunei": _("Brunei"),
	"Bulgaria": _("Bulgaria"),
	"Burkina Faso": _("Burkina Faso"),
	"Burundi": _("Burundi"),
	"Cambodia": _("Cambodia"),
	"Cameroon": _("Cameroon"),
	"Canada": _("Canada"),
	"Cape Verde": _("Cape Verde"),
	"Chad": _("Chad"),
	"Chile": _("Chile"),
	"China": _("China"),
	"Colombia": _("Colombia"),
	"Costa Rica": _("Costa Rica"),
	"Croatia": _("Croatia"),
	"Cuba": _("Cuba"),
	"Curacao": _("Curacao"),
	"Cyprus": _("Cyprus"),
	"Czech Republic": _("Czech Republic"),
	"Democratic Republic of the Congo": _("Democratic Republic of the Congo"),
	"Denmark": _("Denmark"),
	"Djibouti": _("Djibouti"),
	"Dominica": _("Dominica"),
	"Dominican Republic": _("Dominican Republic"),
	"East Timor": _("East Timor"),
	"Ecuador": _("Ecuador"),
	"Egypt": _("Egypt"),
	"El Salvador": _("El Salvador"),
	"Equatorial Guinea": _("Equatorial Guinea"),
	"Estonia": _("Estonia"),
	"Ethiopia": _("Ethiopia"),
	"Faroe Islands": _("Faroe Islands"),
	"Fiji": _("Fiji"),
	"Finland": _("Finland"),
	"France": _("France"),
	"French Guiana": _("French Guiana"),
	"French Polynesia": _("French Polynesia"),
	"Gabon": _("Gabon"),
	"Gambia": _("Gambia"),
	"Georgia": _("Georgia"),
	"Germany": _("Germany"),
	"Ghana": _("Ghana"),
	"Greece": _("Greece"),
	"Greenland": _("Greenland"),
	"Guadeloupe": _("Guadeloupe"),
	"Guam": _("Guam"),
	"Guatemala": _("Guatemala"),
	"Guernsey": _("Guernsey"),
	"Guinea": _("Guinea"),
	"Guyana": _("Guyana"),
	"Haiti": _("Haiti"),
	"Honduras": _("Honduras"),
	"Hong Kong": _("Hong Kong"),
	"Hungary": _("Hungary"),
	"Iceland": _("Iceland"),
	"India": _("India"),
	"Indonesia": _("Indonesia"),
	"Iran": _("Iran"),
	"Iraq": _("Iraq"),
	"Ireland": _("Ireland"),
	"Israel": _("Israel"),
	"Italy": _("Italy"),
	"Ivory Coast": _("Ivory Coast"),
	"Jamaica": _("Jamaica"),
	"Japan": _("Japan"),
	"Jordan": _("Jordan"),
	"Kazakhstan": _("Kazakhstan"),
	"Kenya": _("Kenya"),
	"Kosovo": _("Kosovo"),
	"Kuwait": _("Kuwait"),
	"Kyrgyzstan": _("Kyrgyzstan"),
	"Laos": _("Laos"),
	"Latvia": _("Latvia"),
	"Lebanon": _("Lebanon"),
	"Liberia": _("Liberia"),
	"Libya": _("Libya"),
	"Liechtenstein": _("Liechtenstein"),
	"Lithuania": _("Lithuania"),
	"Luxembourg": _("Luxembourg"),
	"Macao": _("Macao"),
	"Madagascar": _("Madagascar"),
	"Malawi": _("Malawi"),
	"Malaysia": _("Malaysia"),
	"Maldives": _("Maldives"),
	"Mali": _("Mali"),
	"Malta": _("Malta"),
	"Martinique": _("Martinique"),
	"Mauritania": _("Mauritania"),
	"Mayotte": _("Mayotte"),
	"Mexico": _("Mexico"),
	"Micronesia": _("Micronesia"),
	"Moldova": _("Moldova"),
	"Monaco": _("Monaco"),
	"Mongolia": _("Mongolia"),
	"Montenegro": _("Montenegro"),
	"Morocco": _("Morocco"),
	"Mozambique": _("Mozambique"),
	"Myanmar (Burma)": _("Myanmar (Burma)"),
	"Namibia": _("Namibia"),
	"Nepal": _("Nepal"),
	"Netherlands": _("Netherlands"),
	"New Zealand": _("New Zealand"),
	"Nicaragua": _("Nicaragua"),
	"Niger": _("Niger"),
	"Nigeria": _("Nigeria"),
	"North Korea": _("North Korea"),
	"North Macedonia": _("North Macedonia"),
	"Norway": _("Norway"),
	"Oman": _("Oman"),
	"Pakistan": _("Pakistan"),
	"Palestine": _("Palestine"),
	"Panama": _("Panama"),
	"Paraguay": _("Paraguay"),
	"Peru": _("Peru"),
	"Philippines": _("Philippines"),
	"Poland": _("Poland"),
	"Portugal": _("Portugal"),
	"Puerto Rico": _("Puerto Rico"),
	"Qatar": _("Qatar"),
	"Republic of the Congo": _("Republic of the Congo"),
	"Romania": _("Romania"),
	"Russia": _("Russia"),
	"Rwanda": _("Rwanda"),
	"Saint Kitts and Nevis": _("Saint Kitts and Nevis"),
	"Saint Lucia": _("Saint Lucia"),
	"Samoa": _("Samoa"),
	"São Tomé and Príncipe": _("São Tomé and Príncipe"),
	"Saudi Arabia": _("Saudi Arabia"),
	"Senegal": _("Senegal"),
	"Serbia": _("Serbia"),
	"Sierra Leone": _("Sierra Leone"),
	"Singapore": _("Singapore"),
	"Sint Maarten": _("Sint Maarten"),
	"Slovakia": _("Slovakia"),
	"Slovenia": _("Slovenia"),
	"Somalia": _("Somalia"),
	"South Africa": _("South Africa"),
	"South Korea": _("South Korea"),
	"Spain": _("Spain"),
	"Sri Lanka": _("Sri Lanka"),
	"Sudan": _("Sudan"),
	"Suriname": _("Suriname"),
	"Sweden": _("Sweden"),
	"Switzerland": _("Switzerland"),
	"Syria": _("Syria"),
	"Taiwan": _("Taiwan"),
	"Tajikistan": _("Tajikistan"),
	"Tanzania": _("Tanzania"),
	"Thailand": _("Thailand"),
	"Togo": _("Togo"),
	"Trinidad and Tobago": _("Trinidad and Tobago"),
	"Tunisia": _("Tunisia"),
	"Turkey": _("Turkey"),
	"Turkmenistan": _("Turkmenistan"),
	"Uganda": _("Uganda"),
	"Ukraine": _("Ukraine"),
	"United Arab Emirates": _("United Arab Emirates"),
	"United Kingdom": _("United Kingdom"),
	"United States": _("United States"),
	"Uruguay": _("Uruguay"),
	"Uzbekistan": _("Uzbekistan"),
	"Vatican City": _("Vatican City"),
	"Venezuela": _("Venezuela"),
	"Vietnam": _("Vietnam"),
	"Western Sahara": _("Western Sahara"),
	"Yemen": _("Yemen"),
	"Zambia": _("Zambia"),
	"Zimbabwe": _("Zimbabwe"),
	"International": _("International"),

	# genres
	"Animation": _("Animation"),
	"Auto": _("Auto"),
	"Business": _("Business"),
	"Classic": _("Classic"),
	"Comedy": _("Comedy"),
	"Cooking": _("Cooking"),
	"Culture": _("Culture"),
	"Documentary": _("Documentary"),
	"Education": _("Education"),
	"Entertainment": _("Entertainment"),
	"Family": _("Family"),
	"General": _("General"),
	"Kids": _("Kids"),
	"Legislative": _("Legislative"),
	"Lifestyle": _("Lifestyle"),
	"Movies": _("Movies"),
	"Music": _("Music"),
	"News": _("News"),
	"Outdoor": _("Outdoor"),
	"Relax": _("Relax"),
	"Religious": _("Religious"),
	"Science": _("Science"),
	"Series": _("Series"),
	"Shop": _("Shop"),
	"Sports": _("Sports"),
	"Travel": _("Travel"),
	"Weather": _("Weather"),

	# languages
	"Afghan Persian": _("Afghan Persian"),
	"Afrikaans": _("Afrikaans"),
	"Albanian": _("Albanian"),
	"Amharic": _("Amharic"),
	"Arabic": _("Arabic"),
	"Armenian": _("Armenian"),
	"Assamese": _("Assamese"),
	"Assyrian Neo-Aramaic": _("Assyrian Neo-Aramaic"),
	"Aymara": _("Aymara"),
	"Azerbaijani": _("Azerbaijani"),
	"Bashkir": _("Bashkir"),
	"Basque": _("Basque"),
	"Belarusian": _("Belarusian"),
	"Bengali": _("Bengali"),
	"Bhojpuri": _("Bhojpuri"),
	"Bosnian": _("Bosnian"),
	"Bulgarian": _("Bulgarian"),
	"Burmese": _("Burmese"),
	"Catalan": _("Catalan"),
	"Central Kurdish": _("Central Kurdish"),
	"Chhattisgarhi": _("Chhattisgarhi"),
	"Chinese": _("Chinese"),
	"Croatian": _("Croatian"),
	"Czech": _("Czech"),
	"Danish": _("Danish"),
	"Dhanwar (Nepal)": _("Dhanwar (Nepal)"),
	"Dhivehi": _("Dhivehi"),
	"Dholuo": _("Dholuo"),
	"Dimili": _("Dimili"),
	"Dutch": _("Dutch"),
	"English": _("English"),
	"Estonian": _("Estonian"),
	"Ewe": _("Ewe"),
	"Faroese": _("Faroese"),
	"Fataleka": _("Fataleka"),
	"Finnish": _("Finnish"),
	"French": _("French"),
	"Galician": _("Galician"),
	"Galolen": _("Galolen"),
	"Georgian": _("Georgian"),
	"German": _("German"),
	"Greek": _("Greek"),
	"Gujarati": _("Gujarati"),
	"Hausa": _("Hausa"),
	"Hebrew": _("Hebrew"),
	"Hindi": _("Hindi"),
	"Hungarian": _("Hungarian"),
	"Icelandic": _("Icelandic"),
	"Indonesian": _("Indonesian"),
	"Irish": _("Irish"),
	"Isekiri": _("Isekiri"),
	"Italian": _("Italian"),
	"Japanese": _("Japanese"),
	"Kannada": _("Kannada"),
	"Kazakh": _("Kazakh"),
	"Khmer": _("Khmer"),
	"Kinyarwanda": _("Kinyarwanda"),
	"Kirghiz": _("Kirghiz"),
	"Konkani (macrolanguage)": _("Konkani (macrolanguage)"),
	"Korean": _("Korean"),
	"Kurdish": _("Kurdish"),
	"Lahnda": _("Lahnda"),
	"Lao": _("Lao"),
	"Latin": _("Latin"),
	"Latvian": _("Latvian"),
	"Letzeburgesch": _("Letzeburgesch"),
	"Lithuanian": _("Lithuanian"),
	"Macedonian": _("Macedonian"),
	"Malay": _("Malay"),
	"Malayalam": _("Malayalam"),
	"Maltese": _("Maltese"),
	"Mandarin Chinese": _("Mandarin Chinese"),
	"Marathi": _("Marathi"),
	"Min Nan Chinese": _("Min Nan Chinese"),
	"Mongolian": _("Mongolian"),
	"Montenegrin": _("Montenegrin"),
	"Mycenaean Greek": _("Mycenaean Greek"),
	"Nepali": _("Nepali"),
	"Norwegian": _("Norwegian"),
	"Norwegian Bokmål": _("Norwegian Bokmål"),
	"Oriya (macrolanguage)": _("Oriya (macrolanguage)"),
	"Panjabi": _("Panjabi"),
	"Parsi-Dari": _("Parsi-Dari"),
	"Pashto": _("Pashto"),
	"Persian": _("Persian"),
	"Polish": _("Polish"),
	"Portuguese": _("Portuguese"),
	"Romanian": _("Romanian"),
	"Romany": _("Romany"),
	"Russian": _("Russian"),
	"Santali": _("Santali"),
	"Serbian": _("Serbian"),
	"Serbo-Croatian": _("Serbo-Croatian"),
	"Sindhi": _("Sindhi"),
	"Sinhala": _("Sinhala"),
	"Slovak": _("Slovak"),
	"Slovenian": _("Slovenian"),
	"Somali": _("Somali"),
	"Spanish": _("Spanish"),
	"Swahili": _("Swahili"),
	"Swedish": _("Swedish"),
	"Tagalog": _("Tagalog"),
	"Tajik": _("Tajik"),
	"Tamil": _("Tamil"),
	"Telugu": _("Telugu"),
	"Tetum": _("Tetum"),
	"Thai": _("Thai"),
	"Tigrinya": _("Tigrinya"),
	"Turkish": _("Turkish"),
	"Turkmen": _("Turkmen"),
	"Ukrainian": _("Ukrainian"),
	"Urdu": _("Urdu"),
	"Uzbek": _("Uzbek"),
	"Vietnamese": _("Vietnamese"),
	"Yucatec Maya": _("Yucatec Maya"),
	"Yue Chinese": _("Yue Chinese"),
	"Undefined": _("Undefined"),
}
